<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
 <!DOCTYPE html>
<html>

<head>
	<base href="/">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    

    <title>用户</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="static/templet/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="static/templet/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="static/templet/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="static/templet/css/animate.min.css" rel="stylesheet">
    <link href="static/templet/css/style.min862f.css?v=4.1.0" rel="stylesheet">
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">    
        
        	<div class="col-sm-12">
				<form method="POST" enctype="multipart/form-data" action="keyWordG/upload" id = "uploadForm">
        		<table class="table table-hover">
			        <tr>
			        	<td>
			        		<input id='location' class="form-control" disabled>
			        		<input type="file" id="file" name="file" onchange="$('#location').val($('#file').val())" style="display: none">
			        	</td>
			        	<td>
			        		<div class="col-sm-2">
			        		<button type="button" class="btn btn-primary" onclick="$('#file').click();">选择文件</button>
				            </div>
			            </td>
			            <td>
			            	<input class="form-control layer-date" name="importTime"  id="importTime" readonly onclick="laydate({format: 'YYYY-MM-DD 00:00:00',max:laydate.now(0)})" placeholder="请选择日期">
			            </td>
			            <td>
			            	<button type="button" class="btn btn-primary" onclick="upload();">导入</button>
			            </td>
			            
			        </tr>
			    </table>
				</form>   
			</div>      
         	<div class="col-sm-12">
         		<div class="ibox float-e-margins">
                    <div class="ibox-content">
                    	<c:if test="${result.result.state eq '0'}">
                        <table class="table table-hover" id="keyWordTable">
                            <thead>
                            	<tr class="text-left">
                            		<td class="text-error" style="font-size:26px">导入失败,${result.result.message }</td>
                                </tr>
                            </thead>
                            <tbody>
                            	<c:forEach items="${result.keyWordErrorList}" var="key" varStatus="vs">
	                            	<tr class="text-left">
	                            			<td class="text-danger" style="font-size:20px">${key }</td>
	                                </tr>
                                </c:forEach>
                            </tbody>
                        </table>
                        </c:if>
                        <c:if test="${result.result.state eq '1'}">
                        <table class="table table-hover" id="keyWordTable">
                            <tbody>
                            	<tr class="text-left">
                            		<td class="text-success" style="font-size:26px">导入成功,一共导入 ${result.importNum }行,成功 ${result.importNum - result.errNum }行，有 ${result.errNum }行不存在。</td>
                                	<td>
			            				<button type="button" class="btn btn-primary" onclick="table2Excel();">导出</button>
			            			</td>
                                </tr>
                                
                            </tbody>
                        </table>
                        <table border="1" id="table2excel" style="display: none">
                        <c:forEach items="${result.keyWordError}" var="key" varStatus="vs">
	                            	<tr>
	                            			<td>${key.name }</td>
	                            			<td>${key.domain }</td>
	                            			<td>
	                            			${"01" eq key.engineCode?"百度PC":"百度移动"}
	                            			</td>
	                                </tr>
                                </c:forEach>
                        </table>
                        </c:if>
                    </div>
                </div>
         	</div>
         	
        </div>
        
    </div>
    <script src="static/templet/js/jquery.min.js?v=2.1.4"></script>
    <script src="static/templet/js/bootstrap.min.js?v=3.3.5"></script>
    <script src="static/templet/js/plugins/peity/jquery.peity.min.js"></script>
    <script src="static/templet/js/plugins/layer/layer.min.js"></script>
    <script src="static/templet/js/iframe.min.js"></script>
    <script src="static/templet/js/jquery.table2excel.js"></script>
    <script src="static/templet/js/plugins/layer/laydate/laydate.js"></script>
    <script type="text/javascript">
    //导入
    function upload(){
    	var load = layer.load(1, {
	        shade: [0.1,'#fff']
	    });
    	
    	if($('#file').val() == ''){
			layer.msg('请选择文件', {icon: 1});
			layer.close(load);
			return;
		}
    	
		if($('#importTime').val() == ''){
			layer.msg('请选择日期', {icon: 1});
			layer.close(load);
			return;
		}
    	$("#uploadForm").submit();
    }
    
	
    </script>
    
    <script>
		function table2Excel(){
			$("#table2excel").table2excel({
				exclude: ".noExl",//class="noExl"的列不导出
				name: "Excel Document Name",
				filename: "异常数据-"+"${importTime}.xls",//文件名称
				fileext: ".xls",//文件后缀名
				exclude_img: true,//导出图片
				exclude_links: true,//导出超链接
				exclude_inputs: true//导出输入框内容
			});
		}
       
    </script>
    

</body>

</html>